package doyouknow.group.CnAndZhb.service.impl;

import doyouknow.group.CnAndZhb.dao.third.TblGatewayDao;
import doyouknow.group.CnAndZhb.entity.TblGateway;
import doyouknow.group.CnAndZhb.service.TblGatewayService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TblGateway)表服务实现类
 *
 * @author makejava
 * @since 2020-11-10 17:27:46
 */
@Service("tblGatewayService")
public class TblGatewayServiceImpl implements TblGatewayService {
    @Resource
    private TblGatewayDao tblGatewayDao;

    /**
     * 通过ID查询单条数据
     *
     * @param gatewayidx 主键
     * @return 实例对象
     */
    @Override
    public TblGateway queryById(Integer gatewayidx) {
        return this.tblGatewayDao.queryById(gatewayidx);
    }


    @Override
    public TblGateway queryByMac(String mac) {
        return this.tblGatewayDao.queryByMac(mac);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TblGateway> queryAllByLimit(int offset, int limit) {
        return this.tblGatewayDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tblGateway 实例对象
     * @return 实例对象
     */
    @Override
    public TblGateway insert(TblGateway tblGateway) {
        this.tblGatewayDao.insert(tblGateway);
        return tblGateway;
    }

    /**
     * 修改数据
     *
     * @param tblGateway 实例对象
     * @return 实例对象
     */
    @Override
    public TblGateway update(TblGateway tblGateway) {
        this.tblGatewayDao.update(tblGateway);
        return this.queryById(tblGateway.getGatewayidx());
    }

    /**
     * 通过主键删除数据
     *
     * @param gatewayidx 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer gatewayidx) {
        return this.tblGatewayDao.deleteById(gatewayidx) > 0;
    }
}